package com.morningstar.qs.api.basic.util;

import java.io.File;
import java.io.InputStream;
import java.io.StringReader;
import java.util.List;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

@Deprecated
public class XmlHandler {
	private static SAXBuilder saxBuilder = new SAXBuilder();
	
	@SuppressWarnings("unchecked")
	public static List<Element> list(File file){
		List<Element> list=null;
		try {
			Document doc=saxBuilder.build(file);
			if(doc!=null){
				Element root=doc.getRootElement();
				list=root.getChildren();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return list;
	}
	@SuppressWarnings("unchecked")
	@Deprecated
	public static List<Element> list(InputStream in) throws Exception{
		List<Element> list=null;
		Document doc=saxBuilder.build(in);
		if(doc!=null){
			Element root=doc.getRootElement();
			list=root.getChildren();
		}		
		return list;
	}
	
	@Deprecated
	public static Document convertString2Document(String str) throws Exception{
		StringReader read = new StringReader(str);
		Document doc=saxBuilder.build(read);
		if(read!=null){
			read.close();
		}
		return doc;
	}
}
